package com.bawei.android_mianshi.service

import android.app.Notification
import android.app.Service
import android.content.Intent
import android.os.IBinder
import android.util.Log
import com.bawei.android_mianshi.MainActivity2
import com.bawei.android_mianshi.R

class OneService : Service() {

    override fun onBind(intent: Intent): IBinder {
        TODO("Return the communication channel to the service.")
    }

    override fun onCreate() {
        super.onCreate()
        Log.d("OneService", "onCreate: ")
        Thread.sleep(60*1000)
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Log.d("OneService", "onStartCommand: "+intent)
//        var notification = Notification.Builder(this)
//            .setSmallIcon(R.mipmap.ic_launcher)
//            .setContentText("我是一个前台通知")
//            .build()
//
//        //开启前台服务
//        startForeground(1,notification)
        return START_STICKY//异常kill 自动启动 intent为kong
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.d("OneService", "onDestroy: ")
    }
}